<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>创建和删除节点</title>
	</head>
	<body>
		<input type="text" id="txt" />
		<input type="button" value="删除li" id="deleteBtn" />
		<input type="button" value="创建li" id="addBtn" />
		
		<ul id="ul"></ul>
		<script>
			var txt=document.getElementById('txt');
			var delBtn=document.getElementById('deleteBtn');
			var addBtn=document.getElementById('addBtn');
			var ul=document.getElementById('ul');
			
			addBtn.onclick=function(){
				var li=document.createElement('li');
				li.innerHTML=txt.value;
				ul.appendChild(li);
			};
			delBtn.onclick=function(){
				ul.lastElementChild.remove();
			}
		</script>
	</body>
</html>
